<?php


namespace App\Dao;


use App\Model\TaskTag;

class TaskTagDao extends AbstractDao
{
    public function where(array $where): \Hyperf\Database\Model\Builder
    {
        $builder = TaskTag::query();

        foreach ($where as $field => $value) {
            switch ($field) {
                case 'cooperative_id':
                    $builder->where('cooperative_id', $value);
                    break;
                default:
                    if (is_array($value)) {
                        $builder->where($field, $value[0], $value[1]);
                    } else {
                        $builder->where($field, $value);
                    }
            }
        }
        return $builder;
    }


    public function whereIn(array $where, array $fields = [])
    {
        $builder = TaskTag::query();
        foreach ($where as $key => $value) {
            $builder->whereIn($key, $value);
        }
        if ($fields) {
            $builder->select($fields);
        }

        return $builder->get()->toArray();
    }
}